using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Challan
/// </summary>
public class Challan
{
    #region Member Variables

    string status;
    public string Status
    {
        get { return status; }
        set { status = value; }
    }
    string ticketNo;

    public string TicketNo
    {
        get { return ticketNo; }
        set { ticketNo = value; }
    }
    int challanId;
    public int ChallanId
    {
        get
        {
            return challanId;
        }
        set { challanId = value; }
    }
    int suppCompId;
    public int SuppCompId
    {
        get
        {
            return suppCompId;
        }
        set
        {
            suppCompId = value;
        }
    }
    int contractorCompId;
    public int ContractorCompId
    {
        get { return contractorCompId; }
        set { contractorCompId = value; }

    }
    int transportCompId;
    public int TransportCompId
    {
        get { return transportCompId; }
        set { transportCompId = value; }
    }
    int truckId;
    public int TruckId
    {
        get { return truckId; }
        set { truckId = value; }
    }
    int driverId;
    public int DriverId { get { return driverId; } set { driverId = value; } }
    int cleanerId;
    public int CleanerId { get { return cleanerId; } set { cleanerId = value; } }
    DateTime challanDate;
    public DateTime ChallanDate
    {
        get { return challanDate; }
        set { challanDate = value; }
    }
    int challanNo;
    public int ChallanNo
    {
        get { return challanNo; }
        set { challanNo = value; }
    }
    Decimal cft;
    public decimal CFT
    {
        get { return cft; }
        set { cft = value; }
    }

    string cftVal;
    public string CFTVal
    {
        get { return cftVal; }
        set { cftVal = value; }
    }

    byte[] challanCopy;
    public byte[] ChallanCopy
    {
        set { challanCopy = value; }
        get { return challanCopy; }
    }
    int userId;
    public int UserId
    {
        get { return userId; }
        set { userId = value; }
    }
    string transComp;
    public string TransComp
    {
        get { return transComp; }
        set { transComp = value; }
    }

    string suppComp;
    public string SuppComp
    {
        get { return suppComp; }
        set { suppComp = value; }
    }

    string contComp;
    public string ContComp
    {
        get { return contComp; }
        set { contComp = value; }
    }

    string driver;
    public string Driver
    {
        get { return driver; }
        set { driver = value; }
    }

    string cleaner;
    public string Cleaner
    {
        get { return cleaner; }
        set { cleaner = value; }
    }

    string truckNo;
    public string TruckNo
    {
        get { return truckNo; }
        set { truckNo = value; }
    }
    string comment;
    public string Comment
    {
        get { return comment; }
        set { comment = value; }
    }
    int material;
    public int Material { get { return material; } set { material = value; } }
    string materialDetails;
    public string MaterialDetail
    {
        get { return materialDetails; }
        set { materialDetails = value; }
    }
    #endregion
    public Challan()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public Challan(int challanId)
    {
        try
        {
            DataTable dt = new DataTable();
            dt = BusinessClass.GetChallanDetails(challanId);
            if (dt != null && dt.Rows.Count > 0)
            {
                ChallanId = Convert.ToInt32(dt.Rows[0]["ChallanId"]);
                ChallanNo = Convert.ToInt32(dt.Rows[0]["ChallanNo"]);
                ChallanDate = Convert.ToDateTime(dt.Rows[0]["ChallanDate"]);
                CFT = Convert.ToDecimal(dt.Rows[0]["CFT"]);
                TransportCompId = Convert.ToInt32(dt.Rows[0]["TansportComp"]);
                SuppCompId = Convert.ToInt32(dt.Rows[0]["SupplierComp"]);
                ContractorCompId = Convert.ToInt32(dt.Rows[0]["ContractorComp"]);
                TruckId = Convert.ToInt32(dt.Rows[0]["TruckNo"]);
                DriverId = Convert.ToInt32(dt.Rows[0]["DriverId"]);
                CleanerId = Convert.ToInt32(dt.Rows[0]["CleanerId"]);
                Status = Convert.ToString(dt.Rows[0]["Status"]);
                Comment = Convert.ToString(dt.Rows[0]["Comment"]);
                TicketNo = Convert.ToString(dt.Rows[0]["TicketNo"]);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

    }
    public Challan(int challanId, int status)
    {
        DataTable dt = new DataTable();
        dt = BusinessClass.GetChallanDetails("", "", "", challanId, -1);
        if (dt != null && dt.Rows.Count == 1)
        {
            ChallanId = Convert.ToInt32(dt.Rows[0]["ChallanId"]);
            ChallanNo = Convert.ToInt32(dt.Rows[0]["ChallanNo"]);
            ChallanDate = Convert.ToDateTime(dt.Rows[0]["ChallanDate"]);
            CFTVal = Convert.ToString(dt.Rows[0]["CFT"]);
            CFT = Convert.ToDecimal(dt.Rows[0]["CFT1"]);
            TransComp = Convert.ToString(dt.Rows[0]["TransportCompany"]);
            SuppComp = Convert.ToString(dt.Rows[0]["SupplierCompany"]);
            ContComp = Convert.ToString(dt.Rows[0]["ContractorCompany"]);
            TruckNo = Convert.ToString(dt.Rows[0]["TruckNo"]);
            Driver = Convert.ToString(dt.Rows[0]["Driver"]);
            Cleaner = Convert.ToString(dt.Rows[0]["Cleaner"]);
            Status = Convert.ToString(dt.Rows[0]["Status"]);
            Comment = Convert.ToString(dt.Rows[0]["Comment"]);
            MaterialDetail = Convert.ToString(dt.Rows[0]["Material"]);
            TicketNo = Convert.ToString(dt.Rows[0]["TicketNo"]);
        }
    }
    public int CreateChallan()
    {
        try
        {
            int res = 0;
            res = DataAccessClass.CreateChallan(ChallanId, ChallanNo, ChallanDate, SuppCompId, ContractorCompId, TransportCompId, CFT, DriverId, CleanerId, TruckId, Material, ChallanCopy, UserId,TicketNo);
            return res;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    public int CreateChallan(string dtr)
    {
        try
        {
            int res = 0;
            res = DataAccessClass.CreateChallan(ChallanId, ChallanNo, ChallanDate, SuppComp, ContComp, TransComp, CFT, Driver, Cleaner, TruckNo, MaterialDetail, ChallanCopy, UserId,TicketNo);
            return res;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    public DataTable ListChallan(string challanDate, string transportComp, string challanNo, int challanid, int status)
    {
        DataTable dt = new DataTable();
        dt = BusinessClass.GetChallanDetails(challanDate, transportComp, challanNo, challanid, status);
        return dt;

    }

    public DataTable GetBillDetails(string FromDate, string ToDate)
    {
        DataTable dt = new DataTable();
        dt = BusinessClass.GetBillDetails(FromDate, ToDate, TransComp, ContComp, MaterialDetail);
        return dt;
    }
}
